package com.handler

import com.amazonaws.services.s3.model.CannedAccessControlList
import com.amazonaws.services.s3.transfer.MyTransferManager

/**
 * 权限
 */
class AuthorityHandler(transferManager: MyTransferManager?) : BaseHandler<String>(transferManager) {
    override fun execute(value: String) {
        val ol = s3Client?.listObjects(value)
        val objects = ol?.objectSummaries
        println(" len = " + objects?.size)
        if (objects != null) {
            for (os in objects) {
    //            System.out.println("* " + os.getKey());
                s3Client?.setObjectAcl(
                    value,
                    os.key,  //                    CannedAccessControlList.Private
                    CannedAccessControlList.PublicRead
                )
            }
        }
    }
}
